//
//  XS_AboutVC.swift
//  XueDao
//
//  Created by Mac on 2020/12/11.
//

import UIKit

class XS_AboutVC: XS_BaseVC {
//    let titleStr : [String] = ["产品简介", "隐私政策", "服务协议", "付费协议"]
    let titleStr : [String] = ["隐私政策", "服务协议", "付费协议", "免责协议"]

    @IBOutlet weak var tableView: UITableView!
    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        view.backgroundColor = #colorLiteral(red: 0.968627451, green: 0.968627451, blue: 0.968627451, alpha: 1)
        title = "关于我们"
        tableView.contentInset = UIEdgeInsets.init(top: 0, left: 0, bottom: .bottomHeight, right: 0)
        tableView.register(UINib.init(nibName: "XS_SetListCell", bundle: Bundle.main), forCellReuseIdentifier: "XS_SetListCell")
        tableView.delegate = self
        tableView.dataSource = self
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destination.
        // Pass the selected object to the new view controller.
    }
    */

}

extension XS_AboutVC : UITableViewDelegate,UITableViewDataSource{
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return titleStr.count
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "XS_SetListCell", for: indexPath) as! XS_SetListCell
        cell.nextImageView.isHidden = false
//        switch indexPath.row {
//        case 0:
//            cell.titleLabel.text = "产品简介"
//            break
//        case 1:
//            cell.titleLabel.text = "隐私政策"
//            break
//        case 2:
//            cell.titleLabel.text = "服务协议"
//            break
//        case 3:
//            cell.titleLabel.text = "使用协议"
//            break
//        case 4:
//            cell.titleLabel.text = "付费协议"
//            break
//        case 5:
//            cell.titleLabel.text = "退费规则"
//            break
//        default:
//            break
//        }
        cell.titleLabel.text = titleStr[indexPath.row]
        cell.rightLabel.text = ""
        cell.cellarSwitch.isHidden = true
        cell.rightNextLabel.text = ""
        return cell
    }
    
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 50
    }
    
    func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        return 8
    }
    
    func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
        let view = UIView.init(frame: CGRect.init(x: 0, y: 0, width: .screenWidth, height: 8))
        view.backgroundColor = UIColor.qmui_color(withHexString: "#F7F7F7")
        return view
    }
    
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
//        http://xdapp.yaoxuedao.com.cn/productPresentation   产品简介
//         /privacyPolicy   隐私政策
//        /serviceAgreement   服务协议
//        /protocolUsage     使用协议
//        /paymentAgreement  付费协议
//        /refundRules  退费规则
        let urlPrefix = "http://xdapp.yaoxuedao.com.cn/"
//        let urlSuffixArr = ["productPresentation","privacyPolicy","serviceAgreement","protocolUsage","paymentAgreement","refundRules"] // exemption // continuousPackageYear
//        let urlSuffixArr = ["productPresentation","privacyPolicy","serviceAgreement","paymentAgreement"]
        let urlSuffixArr = ["privacyPolicy","serviceAgreement","paymentAgreement","exemption"]
        let webVC = XS_WebPageVC()
        webVC.loadUrl(urlPrefix + urlSuffixArr[indexPath.row])
        navigationController?.pushViewController(webVC, animated: true)
    }
}
